﻿using Application.AppService;
using Application.Dto;
using AutoMapper;
using Domain.Entity;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using UI7_2.Models;

namespace UI7_2.Controllers
{
    public class UserController : Controller
    {
        private readonly ILogger<HomeController> logger;
        private readonly IUserAppService userAppService1;
        public UserController(ILogger<HomeController> logger, IUserAppService userAppService1)
        {
            this.userAppService1 = userAppService1;
            this.logger = logger;
        }

        public IActionResult Index()
        {
            return View();
        }
		public IActionResult right_add()
		{
			return View();
		}
		public bool AddRoles(RolesDto roles)
		{
			return userAppService1.AddRoles(roles);
		}

		public List<Trees2> trees(string id)
		{
			return userAppService1.trees(id);
		}
		public List<Jurisdiction> trees2()
		{
			return userAppService1.trees2();
		}

		[HttpGet]
		public async Task<ActionResult> selectRolesJurisdiction(int id)
		{
			var cMs = await userAppService1.selectRolesJurisdiction(id);
			return Json(cMs);
		}
		[HttpGet]
		public List<Roles> Shwo(int id)
		{
			return userAppService1.Shwo(id);
		}
		[HttpGet]
		public bool UpdateRole(string RolesName, string RolesInstruction, int RolesIf, string JuriID, int RolesID)
		{
			return userAppService1.UpdateRole(RolesName, RolesInstruction, RolesIf, JuriID, RolesID);
		}

		public IActionResult right_list_information()
		{
			return View();
		}
		public bool DeleteRoles(int id)
		{
			return userAppService1.DeleteRoles(id);
		}

		public IActionResult rolemanagement()
		{
			return View();
		}
		public IActionResult yh()
		{
			return View();
		}
		public IActionResult yhxg()
		{
			return View();
		}
		public IActionResult yhtj()
		{
			return View();
		}
		[HttpGet]
		public List<CPC> GetName(CPCDto cPCDto)
		{
			return userAppService1.GetName(cPCDto);
		}
		[HttpGet]
		public List<User> GetUsers(int id)
		{
			return userAppService1.GetUsers(id);
		}
		public bool UserDelete(UserSelectDto userSelectDto)
		{
			return userAppService1.UserDelete(userSelectDto);
		}
		public bool UserUpdate(UserSelectDto userSelectDto)
		{
			return userAppService1.UserUpdate(userSelectDto);
		}
		public bool UserAdd(UserSelectDto userSelectDto)
		{
			return userAppService1.UserAdd(userSelectDto);
		}
		public List<User> UserGet()
		{
			return userAppService1.UserGet();
		}

		public Task<List<Jurisdiction>> JurisdictionList()
		{
			return userAppService1.JurisdictionList();
		}

		public List<User> SelectUser(UserSelectDto userSelectDto)
		{

			Console.WriteLine(userSelectDto.UName);
			return userAppService1.UserSelect(userSelectDto);
		}

		public List<Roles> RolesSelect()
		{
			return userAppService1.RolesSelect();
		}

		public IActionResult Privacy()
		{
			return View();
		}
		[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
		public IActionResult Error()
		{
			return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
		}
	}
}
